package ${package.Controller};


import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
import org.springframework.beans.factory.annotation.Autowired;
import com.puj.automatic.mobile.vo.base.BaseVO;
import com.puj.automatic.mobile.vo.base.ResultVO;
import com.puj.automatic.util.NumberUtils;
import org.springframework.web.bind.annotation.*;

<#if restControllerStyle>
    import org.springframework.web.bind.annotation.RestController;
<#else>
    import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
    import ${superControllerClassPackage};
</#if>

/**
* <p>
    * ${table.comment!} 前端控制器
    * </p>
*
* @author ${author}
* @since ${date}
*/
<#if restControllerStyle>
    @RestController
<#else>
    @Controller
</#if>
@RequestMapping("/api<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if
controllerMappingHyphenStyle??>${table.entitySourceName}<#else>${table.entityPath}</#if>")
<#if kotlin>
    class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
        public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
        public class ${table.controllerName} {
    </#if>
    @Autowired
    private ${table.serviceName} ${table.serviceSourceName};

    @GetMapping("/pageList")
    public ResultVO getPageList(BaseVO base, ${table.entityName} param) {
    return ResultVO.success(${table.serviceSourceName}.pageQuery(base.getPage(), base.getNum(), param));
    }

    @GetMapping("/list")
    public ResultVO getPageList(${table.entityName} params) {
    return ResultVO.success(${table.serviceSourceName}.getList(params));
    }

    @PostMapping("/save")
    public ResultVO save${table.entityName}(@RequestBody ${table.entityName} params) {
    // params.setOperatorId(getLoginUserId());
    ${table.serviceSourceName}.edit${table.entityName}(params);
    return ResultVO.success();
    }

    @PostMapping("/use")
    public ResultVO edit${table.entityName}(@RequestBody ${table.entityName} params) {
    // params.setOperatorId(getLoginUserId());
    // params.setGmtModify(new Date());
    ${table.serviceSourceName}.updateById(params);
    return ResultVO.success();
    }

    @DeleteMapping("/delete")
    public ResultVO useEmployee(String ids) {
    ${table.serviceSourceName}.delete${table.entityName} (NumberUtils.stringToLongList(ids), null);
    return ResultVO.success();
    }

    @GetMapping("/getById")
    public ResultVO getById(${table.entityName} params) {
    return ResultVO.success(${table.serviceSourceName}.getById(params.getId()));
    }
    }
</#if>
